﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace GW2_Marketeer__WPF_
{
    public class GWItem : INotifyPropertyChanged
    {
        private string m_sName;
        private string m_sID;
        private int m_nShoppingAmount;
        private int m_nAuctionHousePrice = 0;
        private int m_nMinimumCalculatedPrice = 0;
        private int m_nProfit = 0;
        private double m_nReturnOnInvestment = 0.0;
        private bool m_bCheapestPriceComputed = false;
        private List<string> m_listComponentsRecipe = new List<string>();
        private List<string> m_listShoppingList = new List<string>();
        //List<string> m_listComponentsSalvage;

        public GWItem(string sName)
        {
            m_sName = sName;
        }

        public GWItem(string sName, string sID)
        {
            m_sName = sName;
            m_sID = sID;
        }

        public GWItem(string sName, string sID, IEnumerable<string> sComponents)
        {
            m_sName = sName;
            m_sID = sID;
            m_listComponentsRecipe.AddRange(sComponents.Where(s => !string.IsNullOrWhiteSpace(s)));
        }

        public string Name
        {
            get { return m_sName; }
            set
            {
                m_sName = value;
                NotifyPropertyChanged("Name");
            }
        }
        public string ID
        {
            get { return m_sID; }
            set
            {
                m_sID = value;
                NotifyPropertyChanged("ID");
            }
        }
        public int AuctionHousePrice
        {
            get { return m_nAuctionHousePrice; }
            set
            {
                m_nAuctionHousePrice = value;
                NotifyPropertyChanged("AuctionHousePrice");
            }
        }
        public int MinimumCalculatedPrice
        {
            get { return m_nMinimumCalculatedPrice; }
            set
            {
                m_nMinimumCalculatedPrice = value;
                NotifyPropertyChanged("MinimumCaluclatedPrice");
            }
        }
        public int Profit
        {
            get { return m_nProfit; }
            set
            {
                m_nProfit = value;
                NotifyPropertyChanged("Profit");
            }
        }
        public double ReturnOnInvestment
        {
            get { return m_nReturnOnInvestment; }
            set
            {
                m_nReturnOnInvestment = value;
                NotifyPropertyChanged("ReturnOnInvestment");
            }
        }
        public bool CheapestPriceComputed
        {
            get { return m_bCheapestPriceComputed; }
            set
            {
                m_bCheapestPriceComputed = value;
                NotifyPropertyChanged("CheapestPriceComputed");
            }
        }
        public int ShoppingAmount
        {
            get { return m_nShoppingAmount; }
            set
            {
                m_nShoppingAmount = value;
                NotifyPropertyChanged("ShoppingAmount");
            }
        }


        public void AddComponent(string sComponentName)
        {
            m_listComponentsRecipe.Add(sComponentName);
        }

        public int GetNumComponents()
        {
            return m_listComponentsRecipe.Count;
        }
        public string GetComponentAtIndex(int nIndex)
        {
            return m_listComponentsRecipe[nIndex];
        }

        public void AddToShoppingList(string sItemName)
        {
            m_listShoppingList.Add(sItemName);
        }
        public int GetNumShoppingList()
        {
            return m_listShoppingList.Count;
        }
        public string GetShoppingListItemAtIndex(int nIndex)
        {
            return m_listShoppingList[nIndex];
        }
        public void ClearShoppingList()
        {
            m_listShoppingList.Clear();
        }
        public List<string> GetShoppingList()
        {
            return m_listShoppingList;
        }

        #region INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }
}
